// 1. const num of nums
var removeElement = function (nums, val) {
    let ans = 0;
    for (const num of nums) {
        if (num != val) {
            nums[ans] = num;
            ans++;
        }
    }
    return ans;
};
// 2. 普通for循环
var removeElement = function (nums, val) {
    let a = 0;

    for (let i = 0; i < nums.length; i++) {
        const num = nums[i]
        if (num != val) {
            nums[a] = num,
                a++
        }
    }
    return a++
}
